% File: testbench_macro_sc_fde_ib_qam.m
% -------------------------------------

close all
clear all

chan_profile    = 7;
mu_profile      = 0;
sig_pac_profile = 17;
code_profile    = 0;
sim_profile     = 9;
scrambl_profile = 0;
intlv_profile   = 1;

rx_array = [6 7 8];
% N_IB = 5; % iteration limit of ib-dfe
N_IB = 3; % iteration limit of ib-dfe
for idx_rx = 1:length(rx_array)
    sc_fde_preprocess

    rx_profile = rx_array(idx_rx);
    sc_fde_base

    sc_fde_postprocess
end

chan_profile    = 7;
mu_profile      = 0;
sig_pac_profile = 18;
code_profile    = 0;
sim_profile     = 10;
scrambl_profile = 0;
intlv_profile   = 1;

rx_array = [6 7 8];
% N_IB = 5; % iteration limit of ib-dfe
N_IB = 3; % iteration limit of ib-dfe
for idx_rx = 1:length(rx_array)
    sc_fde_preprocess

    rx_profile = rx_array(idx_rx);
    sc_fde_base

    sc_fde_postprocess
end

chan_profile    = 7;
mu_profile      = 0;
sig_pac_profile = 16;
code_profile    = 0;
sim_profile     = 6;
scrambl_profile = 0;
intlv_profile   = 1;

rx_array = [6 7 8];
% N_IB = 5; % iteration limit of ib-dfe
N_IB = 3; % iteration limit of ib-dfe
for idx_rx = 1:length(rx_array)
    sc_fde_preprocess

    rx_profile = rx_array(idx_rx);
    sc_fde_base

    sc_fde_postprocess
end

chan_profile    = 7;
mu_profile      = 0;
sig_pac_profile = 17;
code_profile    = 0;
sim_profile     = 7;
scrambl_profile = 0;
intlv_profile   = 1;

rx_array = [6 7 8];
% N_IB = 5; % iteration limit of ib-dfe
N_IB = 3; % iteration limit of ib-dfe
for idx_rx = 1:length(rx_array)
    sc_fde_preprocess

    rx_profile = rx_array(idx_rx);
    sc_fde_base

    sc_fde_postprocess
end

chan_profile    = 7;
mu_profile      = 0;
sig_pac_profile = 18;
code_profile    = 0;
sim_profile     = 8;
scrambl_profile = 0;
intlv_profile   = 1;

rx_array = [6 7 8];
% N_IB = 5; % iteration limit of ib-dfe
N_IB = 3; % iteration limit of ib-dfe
for idx_rx = 1:length(rx_array)
    sc_fde_preprocess

    rx_profile = rx_array(idx_rx);
    sc_fde_base

    sc_fde_postprocess
end

% load testbench_sc_fde_ib_qam_simp_fip_hiperlan2A_2048_8qam_eb_n0_0_16_1000trials.mat
% SER_simp_0_16 = SER;
% load testbench_sc_fde_ib_qam_simp_fip_hiperlan2A_2048_8qam_eb_n0_14_16_5000trials.mat
% SER_simp_14_16 = SER;
% load testbench_sc_fde_ib_qam_simp_fip_hiperlan2A_2048_8qam_eb_n0_18_20_50000trials.mat
% SER_simp_18_20 = SER;
% load testbench_sc_fde_ib_qam_simp_fip_hiperlan2A_2048_8qam_eb_n0_20_20_100000trials.mat
% SER_simp_20 = SER;
% SER_simp_0_20 = [SER_simp_0_16(1:end-2); SER_simp_14_16; SER_simp_18_20(1); SER_simp_20];
% 
% load testbench_sc_fde_ib_qam_evo_fip_hiperlan2A_2048_8qam_eb_n0_0_16_1000trials.mat
% SER_evo_0_16 = SER;
% load testbench_sc_fde_ib_qam_evo_fip_hiperlan2A_2048_8qam_eb_n0_14_16_5000trials.mat
% SER_evo_14_16 = SER;
% load testbench_sc_fde_ib_qam_evo_fip_hiperlan2A_2048_8qam_eb_n0_18_20_50000trials.mat
% SER_evo_18_20 = SER;
% load testbench_sc_fde_ib_qam_evo_fip_hiperlan2A_2048_8qam_eb_n0_20_20_100000trials.mat
% SER_evo_20 = SER;
% SER_evo_0_20 = [SER_evo_0_16(1:end-2); SER_evo_14_16; SER_evo_18_20(1); SER_evo_20];
% 
% load testbench_sc_fde_ib_qam_genie_fip_hiperlan2A_2048_8qam_eb_n0_0_16_1000trials.mat
% SER_genie_0_16 = SER;
% load testbench_sc_fde_ib_qam_genie_fip_hiperlan2A_2048_8qam_eb_n0_14_16_5000trials.mat
% SER_genie_14_16 = SER;
% load testbench_sc_fde_ib_qam_genie_fip_hiperlan2A_2048_8qam_eb_n0_18_20_50000trials.mat
% SER_genie_18_20 = SER;
% load testbench_sc_fde_ib_qam_genie_fip_hiperlan2A_2048_8qam_eb_n0_20_20_100000trials.mat
% SER_genie_20 = SER;
% SER_genie_0_20 = [SER_genie_0_16(1:end-2); SER_genie_14_16; SER_genie_18_20(1); SER_genie_20];
% 
% SER = [SER_simp_0_20 SER_evo_0_20 SER_genie_0_20];
% Eb_N0 = (0:2:20);
% 
% % Plot SER results.
% figure();
% semilogy(Eb_N0,SER,'-*');
% xlabel('Eb/N_0 (dB)'); ylabel('SER');
% ylim([.1e-7 1]);
% grid on
% legend('simp.', 'evo.', 'genie');
% title_string  = sprintf('%dQAM-SC-FDE over %s Fading Channel', M_mod, chan_type);
% title(title_string);

% End of script